home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgramD2.iso
/
Borland
/
Borland C++ V5.02
/
STDLIB.PAK
/
UL_BOUND.CPP
< prev
next >
Wrap
Text File
|
1997-05-06
|
859b
|
35 lines
#include <vector>
#include <algorithm>
using namespace std;
int main ()
{
typedef vector<int>::iterator iterator;
int d1[11] = {0,1,2,2,3,4,2,2,2,6,7};
//
// Set up a vector.
//
vector<int> v1(d1+0, d1+11);
//
// Try lower_bound variants.
//
iterator it1 = lower_bound(v1.begin(),v1.end(),3);
iterator it2 = lower_bound(v1.begin(),v1.end(),2,less<int>());
//
// Try upper_bound variants.
//
iterator it3 = upper_bound(v1.begin(),v1.end(),3);
iterator it4 = upper_bound(v1.begin(),v1.end(),2,less<int>());
cout << endl << endl
<< "The upper and lower bounds of 3: ( "
<< *it1 << " , " << *it3 << " ]" << endl;
cout << endl << endl
<< "The upper and lower bounds of 2: ( "
<< *it2 << " , " << *it4 << " ]" << endl;
return 0;
}